<?
session_start();
include('../config.php');
include("../classes/connect.php");
require_once('../classes/class.jira.php');

if(isset($_GET['fromdate']) AND isset($_GET['todate'])){
	$sql = "select id from trn_emaildetails where deleted=0";
	$postquery = mysql_query($sql);
	$return = array();
	while($row = mysql_fetch_array($postquery)){
		$singlesql = "select * from trn_activity where mainId='".$row['id']."'";
		$singlepost = mysql_query($singlesql);
			while($row2 = mysql_fetch_array($singlepost)){
			$date = $row2['modifiedDate'];
				switch ($row2['status']){
					case $action_one:
						$return[$row['id']][0] = $date;
						break;
					case $action_two:
						$return[$row['id']][1] = $date;
						break;
					case $action_three:
						$return[$row['id']][2] = $date;
						break;
					case $action_four:
						$return[$row['id']][3] = $date;
						break;
					case $action_five:
						$return[$row['id']][4] = $date;
						break;
					case $action_six:
						$return[$row['id']][5] = $date;
						break;
					case $action_seven:
						$return[$row['id']][6] = $date;
						break;
					case $action_eight:
						$return[$row['id']][7] = $date;
						break;
					case $action_nine:
						$return[$row['id']][8] = $date;
						break;
					case $action_ten:
						$return[$row['id']][9] = $date;
						break;
					case $action_eleven:
						$return[$row['id']][10] = $date;
						break;
					case $action_twelve:
						$return[$row['id']][11] = $date;
						break;				
				}
				for ($j=0;$j<12;$j++) {
					if(!isset($return[$row['id']][$j])){
						$return[$row['id']][$j] = "null";
					}
				}
			}

	}

	echo json_encode($return);
}
if(isset($_GET['fromdate1']) AND isset($_GET['todate1'])){
	$fromdate1=$_GET['fromdate1'];
	$todate1=$_GET['todate1'];
	$unixfrom1=strtotime($fromdate1);
	$unixto1=strtotime('+1 day',strtotime($todate1));
	$returnposts= array();
	$postsql="select * from trn_emaildetails where post!=''";
	$postrunsql = mysql_query($postsql);
	while($row3 = mysql_fetch_array($postrunsql)){
		$returnposts[$row3['dateReceived']] = $row3['post'];
	}
	echo json_encode($returnposts);
}
?>		
			
			
			
